// +----------------------------------------------------------------------
// | php_pk_go / for.go [ 2023/3/9 下午8:18 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2023 zhangqiquan All rights reserved.
// +----------------------------------------------------------------------
// | Author: zhangqiquan <768617998@qq.com>
// +----------------------------------------------------------------------
package main
import (
    "fmt"
    "time"
    //"strings"
)

func test() string{
    var str string = "abcdefg123456";
    return str[0:3]
}
// go语言在编译器上做了优化的 像str1只被利用到一次所以只被执行到了一次而，没有执行1亿次
func main() {
    start := time.Now()
    var arr [100000000]string
    for i := 0; i < 100000000; i++ {
        arr[i] = test();
    }
    elapsed := time.Since(start)
    fmt.Println("耗时：", elapsed)
}